home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / FROMUTS / UNIXLIB37B / src / c / strdup < prev    next >
Text File  |  1992-02-17  |  603b  |  38 lines

  1. #ifdef __STDC__
  2. static char sccs_id[] = "@(#) strdup.c 1.0 "__DATE__" HJR";
  3. #else
  4. static char sccs_id[] = "@(#) strdup.c 1.0 8/11/91 HJR";
  5. #endif
  6.  
  7. /* strdup.c (c) Copyright 1990 H.Rogers */
  8.  
  9. #ifndef __STDC__
  10. #include "sys/types.h"
  11. #endif
  12.  
  13. #include <string.h>
  14. #ifdef ARCH
  15. #include "sys/unix.h"
  16. #else
  17. #include <stdlib.h>
  18. #endif
  19.  
  20. #ifdef __STDC__
  21. char *strdup(register const char *s1)
  22. #else
  23. char *strdup(s)
  24. register const char *s1;
  25. #endif
  26. {
  27. #ifdef ARCH
  28. return(__permstr(s1));
  29. #else
  30. register int i = strlen(s1) + 1;
  31. register char *s2;
  32.  
  33. if (!(s2 = malloc(i))) return(0);
  34. memcpy(s2,s1,i);
  35. return(s2);
  36. #endif
  37. }
  38.